SELECT
<#assign prefixName=' '>
<#if (select__id??)>
${prefixName} T.ID AS id
	<#assign prefixName=','>
</#if>
<#if (select__endDaTi??)>
${prefixName} T.END_DA_TI AS endDaTi
	<#assign prefixName=','>
</#if>
<#if (select__operatorId??)>
${prefixName} T.OPERATOR_ID AS operatorId
	<#assign prefixName=','>
</#if>
<#if (select__entityId??)>
${prefixName} T.ENTITY_ID AS entityId
	<#assign prefixName=','>
</#if>
<#if (select__beginDaTi??)>
${prefixName} T.BEGIN_DA_TI AS beginDaTi
	<#assign prefixName=','>
</#if>
<#if (select__userGrId??)>
${prefixName} T.USER_GR_ID AS userGrId
	<#assign prefixName=','>
</#if>
<#if (select__departmentId??)>
${prefixName} T.DEPARTMENT_ID AS departmentId
	<#assign prefixName=','>
</#if>
<#if prefixName == ' '>
  T.ID AS id
, T.END_DA_TI AS endDaTi
, T.OPERATOR_ID AS operatorId
, T.ENTITY_ID AS entityId
, T.BEGIN_DA_TI AS beginDaTi
, T.USER_GR_ID AS userGrId
, T.DEPARTMENT_ID AS departmentId
</#if>
FROM FD_USER_GR_DE T
<#include "whereUserGrDeBy1.ftl">
<#assign prefixName='ORDER BY'>
<#if (order__by__id??)>
${prefixName} T.ID ${order__by__id__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__endDaTi??)>
${prefixName} T.END_DA_TI ${order__by__endDaTi__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__operatorId??)>
${prefixName} T.OPERATOR_ID ${order__by__operatorId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__entityId??)>
${prefixName} T.ENTITY_ID ${order__by__entityId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__beginDaTi??)>
${prefixName} T.BEGIN_DA_TI ${order__by__beginDaTi__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__userGrId??)>
${prefixName} T.USER_GR_ID ${order__by__userGrId__value!}
	<#assign prefixName=','>
</#if>
<#if (order__by__departmentId??)>
${prefixName} T.DEPARTMENT_ID ${order__by__departmentId__value!}
	<#assign prefixName=','>
</#if>
